<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://www.w3.org/1998/Math/MathML">

	<xsl:include href="openmath2mathml.xsl"/>

	<xsl:output method="xml"/>

	<!--xsl:template match="/formalDefinitions"-->
	<!--the path is relative to the output file directory-->
	<!--xsl:processing-instruction name="xml-stylesheet" select="('type=&quot;text/xsl&quot;','href=&quot;../../../../Workspace/GTextbook/src/presentation/style/mathml.xsl&quot;')"/>
		<html>
			<head>
				<title></title>
				<style type="text/css"></style>
			</head>
			<body>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template-->

	<!--xsl:template match="/formalRepresentation"-->
	<!--the path is relative to the output file directory-->
	<!--xsl:processing-instruction name="xml-stylesheet" select="('type=&quot;text/xsl&quot;','href=&quot;../../../../Workspace/GTextbook/src/presentation/style/mathml.xsl&quot;')"/>
		<html>
			<head>
				<title></title>
				<style type="text/css"></style>
			</head>
			<body>
				<h1>
					<xsl:value-of select="@type"/>:<xsl:value-of select="@name"/></h1>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template-->

	<!--xsl:template match="assumption">
		<p>
			<b>Assumption</b><br/>
			<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>;</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</p>
	</xsl:template>


	<xsl:template match="objective">
		<p>
			<b>Show</b><br/>
			<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>;</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</p>
	</xsl:template-->

	<xsl:template match="comment()">
		<h2 align="center">
			<xsl:number count="comment()" level="single" format="I. "/>
			<xsl:value-of select="."/>
		</h2>
	</xsl:template>

	<!--xsl:template match="formalDefinition">
		<h3>
			<xsl:number count="formalDefinition" level="single" format="1. "/>ID: <xsl:value-of select="@objectID"/></h3>
		<p>
			<b>Definition:</b>
			<xsl:apply-templates/>
		</p>
		<hr/>
	</xsl:template-->

	<!--xsl:template match="conceptObject">
		<xsl:choose>
			<xsl:when test="not(parent::argument) and not(parent::reference)">
				<xsl:call-template name="conceptObject"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="conceptObject"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template-->

	<xsl:template match="conceptObject">
		<xsl:choose>
			<xsl:when test="./vocabulary/normalize-space(node())='equal'">
				<xsl:for-each select="./argument/*[not(position()=last())]">
					<xsl:apply-templates select="."/>
					<xsl:text>&#x2261;</xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="./vocabulary/normalize-space(node())='greater'">
				<xsl:for-each select="./argument/*[1]">
					<xsl:apply-templates select="."/>
					<xsl:text>&gt;</xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[2]"/>
			</xsl:when>
			<xsl:when test="./vocabulary/normalize-space(node())='less'">
				<xsl:for-each select="./argument/*[1]">
					<xsl:apply-templates select="."/>
					<xsl:text>&lt;</xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[2]"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="./*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="vocabulary">
		<xsl:value-of select="."/>
	</xsl:template>

	<xsl:template match="argument">
		<xsl:text>(</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>,</xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>)</xsl:text>
	</xsl:template>



	<xsl:template match="pointer">
		<xsl:choose>
			<xsl:when test="parent::return or (parent::binding and contains(@reference,'argument')=false()) or parent::declare or string(@reference)='new::Point'">
				<math:math>
					<xsl:call-template name="pointerwithtype"/>
					<xsl:text> </xsl:text>
				</math:math>
			</xsl:when>
			<xsl:otherwise>
				<math:math>
					<xsl:call-template name="pointerwithouttype"/>
				</math:math>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="pointerwithtype">
		<xsl:choose>
			<xsl:when test="contains(normalize-space(.),'_')">
				<math:msub>
					<math:mi>
						<xsl:value-of select="substring-before(normalize-space(.),'_')"/>
					</math:mi>
					<math:mfenced open="" close="" separator=",">
						<math:mi>
							<xsl:value-of select="substring-after(normalize-space(.),'_')"/>
						</math:mi>
					</math:mfenced>
				</math:msub>
			</xsl:when>
			<xsl:otherwise>
				<math:mi>
					<xsl:value-of select="."/>
				</math:mi>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="@type">
			<math:mtext>
				<xsl:text>::</xsl:text>
				<xsl:value-of select="@type"/>
			</math:mtext>
		</xsl:if>
	</xsl:template>


	<xsl:template name="pointerwithouttype">
		<xsl:choose>
			<xsl:when test="contains(normalize-space(.),'_')">
				<math:msub>
					<math:mi>
						<xsl:value-of select="substring-before(normalize-space(.),'_')"/>
					</math:mi>
					<math:mfenced open="" close="" separator=",">
						<math:mi>
							<xsl:value-of select="substring-after(normalize-space(.),'_')"/>
						</math:mi>
					</math:mfenced>
				</math:msub>
			</xsl:when>
			<xsl:otherwise>
				<math:mi>
					<xsl:value-of select="."/>
				</math:mi>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!--xsl:template name="pointer">
		<xsl:choose>
			<xsl:when test="contains(normalize-space(.),'_')">
				<math:msub>
					<math:mi>
						<xsl:value-of select="substring-before(normalize-space(.),'_')"/>
					</math:mi>
					<math:mfenced open="" close="" separator=",">
						<math:mi>
							<xsl:value-of select="substring-after(normalize-space(.),'_')"/>
						</math:mi>
					</math:mfenced>
				</math:msub>
			</xsl:when>
			<xsl:otherwise>
				<math:mi>
					<xsl:value-of select="."/>
				</math:mi>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="@type">
			<math:mtext>
				<xsl:text>::</xsl:text>
				<xsl:value-of select="@type"/>
			</math:mtext>
		</xsl:if>
	</xsl:template-->

	<xsl:template match="quantity">
		<math:math>
			<xsl:choose>
				<xsl:when test="@type='number'">
					<math:mn>
						<xsl:value-of select="normalize-space(.)"/>
					</math:mn>
				</xsl:when>
				<xsl:otherwise>
					<math:mi>
						<xsl:value-of select="normalize-space(.)"/>
					</math:mi>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="@type">
				<math:mtext>
					<xsl:text>::</xsl:text>
					<xsl:value-of select="@type"/>
				</math:mtext>
			</xsl:if>
		</math:math>
	</xsl:template>

	<!--xsl:template match="nondegeneracyCondition">
		<xsl:if test="./*/*">
			<p>
				<b>NondegeneracyCondition:</b>
				<xsl:apply-templates select="./*"/>
			</p>
		</xsl:if>
	</xsl:template-->

	<xsl:template match="binding">
		<xsl:text>[</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]</xsl:text>
	</xsl:template>

	<!--xsl:template match="constraint">
		<xsl:if test="./*/*">
			<b>
				<xsl:text> Where </xsl:text>
			</b>
			<xsl:apply-templates/>
		</xsl:if>
	</xsl:template-->

	<xsl:template match="return">
		<xsl:text> &#x225C; </xsl:text>
		<xsl:choose>
			<xsl:when test="not(./*)">&#x22A5;</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="./*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="set">
		<xsl:value-of select="@name"/>
		<xsl:text>(</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>,</xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>)</xsl:text>
	</xsl:template>

	<xsl:template match="list">
		<xsl:choose>
			<xsl:when test="not(parent::reference)">
				<xsl:text>{</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>
					<xsl:text>; </xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>}</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="list1"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template name="list1">
		<xsl:text>{</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>; </xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>}</xsl:text>
	</xsl:template>



	<!--xsl:template match="and">
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<br/>&#x2227;</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
	</xsl:template-->

	<xsl:template match="property">
		<xsl:if test="./*">
			<p>
				<b>
					<xsl:text>Property:</xsl:text>
				</b>
				<xsl:apply-templates/>
			</p>
		</xsl:if>
	</xsl:template>


	<xsl:template match="not">
		<xsl:choose>
			<xsl:when test="not(parent::and) and not(parent::or)">
				<xsl:call-template name="not"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="not"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="not">
		<xsl:text>&#xAC;</xsl:text>
		<xsl:text>(</xsl:text>
		<xsl:apply-templates select="./*"/>
		<xsl:text>)</xsl:text>
	</xsl:template>

	<xsl:template match="is">
		<xsl:apply-templates select="./*[1]"/>
		<b>is</b>
		<xsl:apply-templates select="./*[2]"/>
	</xsl:template>

	<xsl:template match="imply">
		<xsl:apply-templates select="./*[1]"/>&#x22A2;   <xsl:apply-templates select="./*[2]"/></xsl:template>


	<xsl:template match="reference">

		<xsl:apply-templates select="./*[1]"/>

		<xsl:text>:=</xsl:text>

		<xsl:apply-templates select="./*[2]"/>
	</xsl:template>

	<xsl:template match="configuration">
		<xsl:for-each select="./*">
			<xsl:apply-templates select="."/>
			<xsl:if test="not(name()='configuration') and not(name()='declare')">
				<xsl:text>; </xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="quantityFunction">
		<xsl:choose>
			<xsl:when test="@name='times'">
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>*</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="@name='plus'">
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>+</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="@name='minus'">
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>-</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:when>
			<xsl:when test="@name='divide'">
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>/</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="@name"/>
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>,</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<!--xsl:template match="declare">
		<div>Declare: <xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>;</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</div>
	</xsl:template>

	<xsl:template match="give">
		<div>Given
			<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>;</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</div>
	</xsl:template-->

	<!--xsl:template match="times">
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<math:mo>*</math:mo>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
	</xsl:template>

	<xsl:template match="plus">
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<math:mo>+</math:mo>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
	</xsl:template>

	<xsl:template match="minus">
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<math:mo>-</math:mo>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
	</xsl:template-->

	<!-- ********************************************************************
       
         Default rule (do NOT delete)
       
       ******************************************************************** -->

	<xsl:template match="*">
		<xsl:copy>
			<xsl:for-each select="@*">
				<xsl:copy/>
			</xsl:for-each>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. 保留所有权力.
<metaInformation>
<scenarios/><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->